<template>
  <div class="mod-config">
    <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
      <el-tab-pane label="加工检验查询" name="first">
        <check-index ref="first" :tableHeight="tableHeight"></check-index>
      </el-tab-pane>
      <el-tab-pane label="加工检验(自动刷新)" name="second">
        <check-auto ref="second" :tableHeight="tableHeight"></check-auto>
      </el-tab-pane>
      <el-tab-pane label="加工检验单打印" name="third">
        <print-index ref="third" :tableHeight="tableHeight"></print-index>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
  import CheckIndex from './components/CheckSearch'
  import CheckAuto from './components/checkAuto'
  import PrintIndex from './components/CheckPrint'
  export default {
    data() {
      return {
        activeName: 'first'
      };
    },
    components: {
      CheckIndex,
      CheckAuto,
      PrintIndex
    },
    computed: {
      tableHeight: function(){
        return window.innerHeight - 260
      }
    },
    created(){
      this.$nextTick(() => {
        this.$refs.first.init()
      })
    },
    methods: {
      handleClick(tab, event) {
        if (tab.name == "first") {
          this.$refs.second.isKeep = false
          this.$refs.first.init()
        } else if (tab.name == "second") {
          this.$refs.second.init()
        }else if(tab.name == 'third'){
          this.$refs.second.isKeep = false
          this.$refs.third.init()
        }
      }
    },
    beforeRouteLeave(to, form, next) {
      this.$refs.second.isKeep = false
      next()
    }
  };
</script>
